inherited sprOtherDogovors: TsprOtherDogovors
  Left = 444
  Top = 335
  Caption = #1057#1087#1088#1072#1074#1086#1095#1085#1080#1082' '#1076#1086#1075#1086#1074#1086#1088#1086#1074' '#1087#1088#1086#1095#1080#1093' '#1087#1083#1072#1090#1077#1078#1077#1081
  PixelsPerInch = 96
  TextHeight = 13
  inherited Panel2: TPanel
    Top = 25
    Height = 529
    inherited PageControl1: TPageControl
      Height = 529
      ActivePage = tsForm
      inherited tsTab: TTabSheet
        inherited GroupBox3: TGroupBox
          Height = 501
          inherited dbgRefer: TDBGridEh
            Height = 484
            Columns = <
              item
                EditButtons = <>
                FieldName = 'ID'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'GROUP_NAME'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'ORG_NAME'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'DOGHEADER'
                Footers = <>
                Width = 174
              end
              item
                EditButtons = <>
                FieldName = 'USERORG_ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'RPT_GROUP_ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'PAY_RATE'
                Footers = <>
                Width = 97
              end
              item
                EditButtons = <>
                FieldName = 'IS_ACTIVE'
                Footers = <>
                Width = 95
              end>
          end
        end
      end
      inherited tsForm: TTabSheet
        inherited GroupBox2: TGroupBox
          Top = 0
          Width = 784
          Height = 501
          Align = alClient
          object Label1: TLabel [0]
            Left = 5
            Top = 27
            Width = 109
            Height = 13
            Alignment = taRightJustify
            AutoSize = False
            Caption = #1059#1089#1083#1091#1075#1072
          end
          object Label2: TLabel [1]
            Left = 5
            Top = 51
            Width = 109
            Height = 29
            Alignment = taRightJustify
            AutoSize = False
            Caption = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103' '#1085#1072#1079#1085#1072#1095#1077#1085#1080#1103
            WordWrap = True
          end
          object Label3: TLabel [2]
            Left = 5
            Top = 84
            Width = 109
            Height = 29
            Alignment = taRightJustify
            AutoSize = False
            Caption = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103' '#1087#1086#1083#1091#1095#1072#1090#1077#1083#1100
            WordWrap = True
          end
          object Label4: TLabel [3]
            Left = 5
            Top = 116
            Width = 109
            Height = 29
            Alignment = taRightJustify
            AutoSize = False
            Caption = #1057#1090#1072#1074#1082#1072' '#1082#1086#1084#1080#1089#1089#1080#1080' '#1089#1074#1077#1088#1093' '#1087#1083#1072#1090#1077#1078#1072
            WordWrap = True
          end
          inherited pnlButtons: TPanel
            Top = 468
            Width = 780
            inherited SpeedButton1: TSpeedButton
              Left = 581
            end
            inherited SpeedButton2: TSpeedButton
              Left = 683
            end
          end
          object lcbGroupName: TDBLookupComboboxEh
            Left = 120
            Top = 24
            Width = 313
            Height = 19
            AlwaysShowBorder = True
            DataField = 'RPT_GROUP_ID'
            DataSource = dscRefer
            EditButtons = <>
            Flat = True
            KeyField = 'ID'
            ListField = 'NAME'
            ListSource = dsc_Groups
            TabOrder = 1
            Visible = True
          end
          object lcbOrgName: TDBLookupComboboxEh
            Left = 120
            Top = 56
            Width = 313
            Height = 19
            AlwaysShowBorder = True
            DataField = 'USERORG_ID'
            DataSource = dscRefer
            EditButtons = <>
            Flat = True
            KeyField = 'ID'
            ListField = 'NAME'
            ListSource = dsc_Orgs
            TabOrder = 2
            Visible = True
          end
          object dbeHeader: TDBEditEh
            Left = 120
            Top = 89
            Width = 313
            Height = 19
            AlwaysShowBorder = True
            DataField = 'DOGHEADER'
            DataSource = dscRefer
            EditButtons = <>
            Flat = True
            TabOrder = 3
            Visible = True
          end
          object dbneRate: TDBNumberEditEh
            Left = 120
            Top = 121
            Width = 77
            Height = 19
            AlwaysShowBorder = True
            DataField = 'PAY_RATE'
            DataSource = dscRefer
            EditButtons = <>
            Flat = True
            TabOrder = 4
            Visible = True
          end
          object cbActive: TDBCheckBoxEh
            Left = 120
            Top = 154
            Width = 233
            Height = 17
            AlwaysShowBorder = True
            Caption = #1055#1088#1080#1079#1085#1072#1082' '#1072#1082#1090#1091#1072#1083#1100#1085#1086#1089#1090#1080' '#1076#1086#1075#1086#1074#1086#1088#1072
            DataField = 'IS_ACTIVE'
            DataSource = dscRefer
            Flat = True
            TabOrder = 5
            ValueChecked = '1'
            ValueUnchecked = '0'
          end
          object GroupBox4: TGroupBox
            Left = 448
            Top = 15
            Width = 334
            Height = 453
            Align = alRight
            Anchors = [akLeft, akTop, akRight, akBottom]
            Caption = ' '#1053#1072#1079#1085#1072#1095#1077#1085#1080#1077' '#1072#1075#1077#1085#1090#1086#1074' '
            TabOrder = 6
            object dbgAgents: TDBGridEh
              Left = 2
              Top = 15
              Width = 330
              Height = 436
              Align = alClient
              AllowedOperations = [alopUpdateEh]
              ColumnDefValues.Title.TitleButton = True
              DataGrouping.GroupLevels = <>
              DataSource = dscAgents
              Flat = True
              FooterColor = clWindow
              FooterFont.Charset = DEFAULT_CHARSET
              FooterFont.Color = clWindowText
              FooterFont.Height = -11
              FooterFont.Name = 'MS Sans Serif'
              FooterFont.Style = []
              IndicatorTitle.TitleButton = True
              OddRowColor = clMoneyGreen
              Options = [dgEditing, dgTitles, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete]
              OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghAutoSortMarking, dghMultiSortMarking, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize, dghColumnMove]
              RowDetailPanel.Color = clBtnFace
              SortLocal = True
              TabOrder = 0
              TitleFont.Charset = DEFAULT_CHARSET
              TitleFont.Color = clWindowText
              TitleFont.Height = -11
              TitleFont.Name = 'MS Sans Serif'
              TitleFont.Style = []
              UseMultiTitle = True
              VTitleMargin = 5
              OnDblClick = aEditExecute
              OnSortMarkingChanged = dbgReferSortMarkingChanged
              Columns = <
                item
                  EditButtons = <>
                  FieldName = 'ID'
                  Footers = <>
                  Visible = False
                end
                item
                  EditButtons = <>
                  FieldName = 'NAME'
                  Footers = <>
                  ReadOnly = True
                  Width = 248
                end
                item
                  Checkboxes = True
                  EditButtons = <>
                  FieldName = 'ACCESS'
                  Footers = <>
                end>
              object RowDetailData: TRowDetailPanelControlEh
              end
            end
          end
        end
      end
    end
  end
  inherited GroupBox1: TGroupBox
    Height = 0
    Enabled = False
    Visible = False
  end
  inherited dsRefer: TpFIBDataSet
    UpdateSQL.Strings = (
      'UPDATE RTP_DOGOVORS'
      'SET '
      '    DOGHEADER = :DOGHEADER,'
      '    PAY_RATE = :PAY_RATE,'
      '    IS_ACTIVE = :IS_ACTIVE'
      'WHERE'
      '    ID = :OLD_ID'
      '    ')
    DeleteSQL.Strings = (
      'DELETE FROM'
      '    RTP_DOGOVORS'
      'WHERE'
      '        ID = :OLD_ID'
      '    ')
    InsertSQL.Strings = (
      'INSERT INTO RTP_DOGOVORS('
      '    USERORG_ID,'
      '    RPT_GROUP_ID,'
      '    DOGHEADER,'
      '    PAY_RATE'
      ')'
      'VALUES('
      '    :USERORG_ID,'
      '    :RPT_GROUP_ID,'
      '    :DOGHEADER,'
      '    :PAY_RATE'
      ')'
      'returning id')
    RefreshSQL.Strings = (
      'select rd.id,'
      '       rd.userorg_id, '
      '       rd.rpt_group_id, '
      '       rd.dogheader, '
      '       rd.pay_rate, '
      '       rd.is_active,'
      '       u.name as org_name,'
      '       rg.name as group_name'
      'from rtp_dogovors rd'
      'join rtp_groups rg on rg.id = rd.rpt_group_id'
      'join userorg u on u.id = rd.userorg_id'
      ''
      ' WHERE '
      '        RD.ID = :OLD_ID'
      '    ')
    SelectSQL.Strings = (
      'select rd.id,'
      '       rd.userorg_id, '
      '       rd.rpt_group_id, '
      '       rd.dogheader, '
      '       rd.pay_rate, '
      '       rd.is_active,'
      '       u.name as org_name,'
      '       rg.name as group_name'
      'from rtp_dogovors rd'
      'join rtp_groups rg on rg.id = rd.rpt_group_id'
      'join userorg u on u.id = rd.userorg_id')
    UpdateTransaction = trRefer
    object dsReferID: TFIBIntegerField
      DisplayLabel = #1048#1044
      FieldName = 'ID'
    end
    object dsReferUSERORG_ID: TFIBIntegerField
      FieldName = 'USERORG_ID'
    end
    object dsReferRPT_GROUP_ID: TFIBIntegerField
      FieldName = 'RPT_GROUP_ID'
    end
    object dsReferDOGHEADER: TFIBStringField
      DisplayLabel = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103'-'#1087#1086#1083#1091#1095#1072#1090#1077#1083#1100
      DisplayWidth = 30
      FieldName = 'DOGHEADER'
      Size = 120
      EmptyStrToNull = True
    end
    object dsReferPAY_RATE: TFIBBCDField
      DisplayLabel = #1057#1090#1072#1074#1082#1072' '#1082#1086#1084#1080#1089#1089#1080#1080' '#1089#1074#1077#1088#1093' '#1087#1083#1072#1090#1077#1078#1072
      FieldName = 'PAY_RATE'
      Size = 2
      RoundByScale = True
    end
    object dsReferIS_ACTIVE: TFIBSmallIntField
      DisplayLabel = #1055#1088#1080#1079#1085#1072#1082' '#1072#1082#1090#1091#1072#1083#1100#1085#1086#1089#1090#1080' '#1076#1086#1075#1086#1074#1086#1088#1072
      FieldName = 'IS_ACTIVE'
    end
    object dsReferORG_NAME: TFIBStringField
      DisplayLabel = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103' '#1085#1072#1079#1085#1072#1095#1077#1085#1080#1103
      DisplayWidth = 30
      FieldName = 'ORG_NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object dsReferGROUP_NAME: TFIBStringField
      DisplayLabel = #1059#1089#1083#1091#1075#1072
      DisplayWidth = 20
      FieldName = 'GROUP_NAME'
      Size = 120
      EmptyStrToNull = True
    end
  end
  inherited Timer1: TTimer
    Left = 548
    Top = 155
  end
  inherited trRefer: TpFIBTransaction
    Top = 280
  end
  inherited trLists: TpFIBTransaction
    Left = 548
    Top = 187
  end
  object ds_Groups: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    NAME,'
      '    IS_ACTIVE'
      'FROM'
      '    RTP_GROUPS '
      'order by 2')
    AfterCancel = dsReferAfterRefresh
    AfterEdit = dsReferAfterEdit
    AfterInsert = dsReferAfterInsert
    AfterOpen = dsReferAfterRefresh
    AfterRefresh = dsReferAfterRefresh
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    AfterFetchRecord = dsReferAfterFetchRecord
    Left = 284
    Top = 156
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object ds_GroupsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_GroupsNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 120
      EmptyStrToNull = True
    end
    object ds_GroupsIS_ACTIVE: TFIBSmallIntField
      FieldName = 'IS_ACTIVE'
    end
  end
  object dsc_Groups: TDataSource
    DataSet = ds_Groups
    Left = 316
    Top = 156
  end
  object ds_Orgs: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    NAME'
      'FROM'
      '    USERORG '
      'order by 2')
    AfterCancel = dsReferAfterRefresh
    AfterEdit = dsReferAfterEdit
    AfterInsert = dsReferAfterInsert
    AfterOpen = dsReferAfterRefresh
    AfterRefresh = dsReferAfterRefresh
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    AfterFetchRecord = dsReferAfterFetchRecord
    Left = 284
    Top = 204
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object ds_OrgsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_OrgsNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
  end
  object dsc_Orgs: TDataSource
    DataSet = ds_Orgs
    Left = 316
    Top = 204
  end
  object dsAgents: TpFIBDataSet
    UpdateSQL.Strings = (
      'update or INSERT INTO RTP_AGENTS(RTP_DOG_ID, USERORG_ID)'
      '  VALUES(:RTP_DOG_ID, :USERORG_ID)'
      '  matching (RTP_DOG_ID, USERORG_ID)    ')
    DeleteSQL.Strings = (
      'DELETE FROM RTP_AGENTS'
      'WHERE RTP_DOG_ID = :OLD_RTP_DOG_ID'
      '  and USERORG_ID = :OLD_USERORG_ID'
      '    ')
    RefreshSQL.Strings = (
      'select v.id, v.name, ra.rtp_dog_id, ra.userorg_id,'
      '       iif(ra.userorg_id is null, 0, 1) as access'
      '  from v_org v'
      '  left join rtp_agents ra on ra.userorg_id = v.id'
      '    and ra.rtp_dog_id = :id'
      ' WHERE V.ID = :OLD_ID'
      '    ')
    SelectSQL.Strings = (
      'select v.id, v.name, ra.rtp_dog_id, ra.userorg_id,'
      '       coalesce(iif(ra.userorg_id is null, 0, 1), 0) as access'
      '  from v_org v'
      '  left join rtp_agents ra on ra.userorg_id = v.id'
      '    and ra.rtp_dog_id = :id'
      '  order by 2')
    AfterCancel = dsReferAfterRefresh
    BeforePost = dsAgentsBeforePost
    Transaction = trRefer
    Database = MAINDM.pMainDatabase
    OnFieldChange = dsAgentsFieldChange
    DataSource = dscRefer
    Left = 548
    Top = 124
    WaitEndMasterScroll = True
    dcForceOpen = True
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsAgentsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object dsAgentsNAME: TFIBStringField
      DisplayLabel = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103
      DisplayWidth = 20
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object dsAgentsRTP_DOG_ID: TFIBIntegerField
      FieldName = 'RTP_DOG_ID'
    end
    object dsAgentsUSERORG_ID: TFIBIntegerField
      FieldName = 'USERORG_ID'
    end
    object dsAgentsACCESS: TFIBIntegerField
      DisplayLabel = #1040#1075#1077#1085#1090
      DisplayWidth = 6
      FieldName = 'ACCESS'
    end
  end
  object dscAgents: TDataSource
    DataSet = dsAgents
    Left = 580
    Top = 124
  end
end
